import requests
from runner import ENV


def merchant_login():
    """商户登录"""
    url = f"{ENV.MER_HOST}/api/admin/merchant/login"
    headers = {'content-type': 'application/json'}
    json = {
        'account': ENV.MER_USERNAME,
        'pwd': ENV.MER_PASSWORD,
        'captchaVO': {},
        'captcha': {
            'captchaVerification': '',
            'secretKey': '',
            'token': '',
        },
    }
    response = requests.post(url, headers=headers,json=json)
    # logger.info(f"接口响应信息为:{response.json()}")
    return response.json()["data"]["token"]

def user_login():
    """用户登录"""
    url = f"{ENV.USER_HOST}/api/front/login/mobile/password"
    headers = {'content-type': 'application/json'}
    json = {
        'phone': ENV.USER_USERNAME,
        'password': ENV.USER_PASSWORD,
        'spreadPid': 0,
    }
    response = requests.post(url,headers=headers,json=json)
    # logger.info(f"接口响应信息为:{response.json()}")
    return response.json()["data"]["token"]
# print(user_login())